<?php
session_start();
//包含头
include '../PHP/head.php';
?>
<?php
//包含bootstrap的顶端按钮
include '../PHP/menu.php';
?>
<?php
//需要判断是哪专业负责人在操作，那些项目需要这些专业报价或提供技术标书
//从user_position中提取专业代码
$subject = substr ($user_position, 1, 2);
$subject = strtolower ($subject);
?>
<br />
<br />
<p class="text-center lead">已完成项目查询</p>
<form class="form-inline" action = "../PHP/show_finished.php" method = "post">
<div class="form-group">
	<label for="year">年份：</label>
	<select class="form-control" name='year'>
		<option value='15'>2015年</option>
		<option value='16'>2016年</option>
	</select>
</div>
<button type="submit" class="btn btn-default">查询</button>
</form>

<?php
require_once ('../FNS/db_fns.php');
//创建短变量并清除前后空格
if(isset($_POST['year'])) {

$year = trim ($_POST['year']);

//判断数据是否为空
if (!$year){
	echo "<p>输入不能为空，请重新选择！</p>";
	echo "</div>";
	echo "</body>";
	exit;
}

//数据过滤和处理

if (! get_magic_quotes_gpc()) {
$year=addslashes ($year);
}

$db = db_connect();
$query="select * from projects where code LIKE 'MP".$year."%' and flag_del = '5' and ".$subject." <> 'none' ORDER BY code";
$result=$db->query ($query);
if (!$result) {
	echo "<br />";
	echo "<p>无记录。</p>";
	echo "</div>";
	echo "</body>";
	$db->close();
exit;
}
$num_result=$result->num_rows;


?>
<br />
<br />
<p class="text-center lead">项目列表：</p>

<?php

//写表头
echo "<table class='table table-striped'>";
echo "<tr>";
	echo "<td align='center' class='info'><strong>报价编号</strong></td>";
	echo "<td align='center' class='info'><strong>项目名称</strong></td>";
	echo "<td align='center' class='info'><strong>报价委托日期</strong></td>";
	echo "<td align='center' class='info'><strong>报价通知日期</strong></td>";
	echo "<td align='center' class='info'><strong>报价截止日期</strong></td>";
	echo "<td align='center' class='info'><strong>操作</strong></td>";
echo "</tr>";



//循环编制表格
for ($i=0; $i < $num_result; $i++) {

	$row=$result->fetch_assoc ();
	
	$project_id = stripslashes ($row['id']);
	$project_code = stripslashes ($row['code']);
	$project_name = stripslashes ($row['name']);
	$deadline = stripslashes ($row['deadline']);
	$entrust_date = stripslashes ($row['entrust_date']);
	$note_date = stripslashes ($row['note_date']);
	$flag_del = stripslashes ($row['flag_del']);
	
	$link_c = "../PHP/show_clarification_status.php?project_id=".$project_id;
	$link_d = "../PHP/show_deviation_status.php?project_id=".$project_id;
	
	echo "<tr>";
	echo "<td align ='center'>".$project_code."</td>";
    echo "<td align ='center'>".$project_name."</td>";
	echo "<td align ='center'>".$entrust_date."</td>";
	echo "<td align ='center'>".$note_date."</td>";
	echo "<td align ='center'>".$deadline."</td>";
	echo "<td align='center'>";
	echo "<a class='btn btn-success btn-sm' href='".$link_c."' role='button'>澄清查看</a> ";
	echo "<a class='btn btn-success btn-sm' href='".$link_d."' role='button'>偏离查看</a> ";
	echo "</td>";
	echo "</tr>";
	
}
echo "</table>";


$result->free();
$db->close();





}


?>


</div>
</body>
</html>
